package com.quan.project.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.quan.common.biz.support.BaseService;
import com.quan.project.system.dto.ProjectGroupByStatus;
import com.quan.project.system.dto.ProjectGroupByYear;
import com.quan.project.system.entity.IeasyOaProjectCenter;
import com.quan.project.system.mapper.IeasyOaProjectCenterMapper;
import com.quan.project.system.service.IeasyOaProjectCenterService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 杨浩泉
 * @since 2019-03-14
 */
@Service
public class IeasyOaProjectCenterServiceImpl extends BaseService<IeasyOaProjectCenter> implements IeasyOaProjectCenterService {
	
	@Autowired
	private IeasyOaProjectCenterMapper mapper ;

	@Override
	public List<IeasyOaProjectCenter> selectDefined() {
		return this.mapper.selectDefined();
	}

	@Override
	public List<ProjectGroupByYear> selectProjectGroupByYear() {
		return this.mapper.selectProjectGroupByYear();
	}

	@Override
	public ProjectGroupByStatus selectProjectGroupByStatus() {
		List<ProjectGroupByStatus> selectProjectGroupByStatus = this.mapper.selectProjectGroupByStatus();
		
		ProjectGroupByStatus ps = new ProjectGroupByStatus() ;
		
		for (ProjectGroupByStatus projectGroupByStatus : selectProjectGroupByStatus) {
			if(projectGroupByStatus.getStatus() == 2) {
				ps.setRuntime(projectGroupByStatus.getCount());
			} else if(projectGroupByStatus.getStatus() == 3) {
				ps.setHangUp(projectGroupByStatus.getCount());
			} else if(projectGroupByStatus.getStatus() == 4) {
				ps.setFinish(projectGroupByStatus.getCount());
			} 
		}
		
		ps.setTotal(ps.getRuntime() + ps.getHangUp() + ps.getFinish());
		
		return ps;
	}
	
}